/**
 * Copyright &copy; 2016-2017 <a href="https://www.lczyfz.com">联创智云</a> All rights reserved.
 */
package com.lczyfz.campusinfo.modules.campusinfo.web;

import com.lczyfz.campusinfo.common.persistence.Page;
import com.lczyfz.campusinfo.common.utils.ApiResultUtils;
import com.lczyfz.campusinfo.common.web.BaseController;
import com.lczyfz.campusinfo.modules.cms.entity.Article;
import com.lczyfz.campusinfo.modules.cms.service.ArticleDataService;
import com.lczyfz.campusinfo.modules.cms.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * 校园通知Controller
 * @author zms
 * @version 2018-03-23
 */
@Controller
@RequestMapping(value = "/api/schoolmessage/notice")
public class SchApiNoticeController extends BaseController {

	@Autowired
	private ArticleService articleService;
	@Autowired
	private ArticleDataService articleDataService;
	@RequestMapping(value = "noticeList")
	@ResponseBody
	public Map<String, Object> getNotice(Article article, HttpServletRequest request, HttpServletResponse response) {
		response.setHeader("Access-Control-Allow-Origin", "*");
		article.setDelFlag("0");
		Page<Article> articlePage = articleService.getClassifyPage(new Page<Article>(request, response), article);
		Map<String, Object> map = ApiResultUtils.getBaseMapSuccess();
		map.put("page", articlePage.getList());
		map.put("pageNo", articlePage.getPageNo());
		map.put("count", articlePage.getCount());
		map.put("totalPage",articlePage.getTotalPage());
		return map;
	}
	@RequestMapping(value = "findById")
	@ResponseBody
	public Map<String, Object> fingId(Article article, HttpServletRequest request, HttpServletResponse response) {
		response.setHeader("Access-Control-Allow-Origin", "*");
		article.setDelFlag("0");
		Article findarticle = articleService.getArticle(article);
		Map<String, Object> map = ApiResultUtils.getBaseMapSuccess();
		map.put("page", findarticle);
		return map;
	}

}